package com.demo.component.base;

import com.demo.component.base.model.communication.RequestResult;
import com.demo.component.base.model.communication.RequestResultData;
import org.springframework.http.HttpHeaders;
import org.springframework.web.client.RestTemplate;


public interface RestTemplateProcessor {
    /**
     *
     * @return
     */
    public RestTemplate getRestTemplate();
    /**
     * Set the appropriate rest template from the desired configuration
     * @param restTemplate
     */
    void setRestTemplate(RestTemplate restTemplate);

    /**
     * Calls a REST GET Request with a RestTemplate that is already authenticated as a Bean Configuration and returns a DTO of type TResultDto
     * @param url
     * @return
     * @param <TResultDto>
     */
    <TResultDto> RequestResultData<TResultDto> getRestReturningData(String url, HttpHeaders headers, Class<TResultDto> responseType);

    /**
     * Calls a REST POST Request with a RestTemplate that is already authenticated as a Bean Configuration and accepts a DTO of type TRequestDto
     * @param requestModel
     * @param url
     * @return
     * @param <TResultDto>
     */
    <TRequestDto, TResultDto> RequestResultData<TResultDto> postRestReturningData(TRequestDto requestModel, String url, HttpHeaders httpHeaders, Class<TResultDto> responseType);
    /**
     * Calls a REST POST Request with a RestTemplate that is already authenticated as a Bean Configuration and accepts a DTO of type TRequestDto
     * @param requestModel
     * @param url
     * @return
     */
    <TRequestDto> RequestResult postRestReturningVoid(TRequestDto requestModel, String url, HttpHeaders httpHeaders );

    //<TRequestDto> RequestResult putRestReturningVoid(TRequestDto requestModel, String url, HttpHeaders httpHeaders );

    /**
     * Calls REST DELETE with a RestTemplate that is already wuthenticated as a Bean Configuration
     * @param url
     * @return
     */
    RequestResult executeRestDelete(String url, HttpHeaders httpHeaders);

    <TResultDto> RequestResultData<TResultDto> deleteRestReturningData(String url, HttpHeaders httpHeaders, Class<TResultDto> responseType);

    public <T> RequestResult putRestReturningVoid(T requestModel, String url, HttpHeaders httpHeaders);

    <TRequestDto, TResultDto> RequestResultData<TResultDto> putRestReturningData(TRequestDto requestModel, String url, HttpHeaders httpHeaders, Class<TResultDto> responseType);

    <TRequestDto, TResultDto> RequestResultData<TResultDto> patchRestReturningData(TRequestDto requestModel, String url, HttpHeaders httpHeaders, Class<TResultDto> responseType);
}
